<template>
  <div>
    <el-form-item
      :label="parentNoTitle"
      label-width="150px"
      class="normal-type"
    >
      <div slot="label">
        <span style="color:#ff0000">*</span>{{ parentNoTitle }}
      </div>
      <el-select
        v-model="shippingWay"
       style="width: 635px" placeholder="请选择"    @change="initSpecialScene">
        <el-option
          v-for="(item, value) in logisticsMethodMap"
          :key="value"
          :label="item"
          :value="value"
        />
      </el-select>
    </el-form-item>
    <el-form-item
      :label="parentNoTitle1"
      label-width="150px"
      class="normal-type"
    >
      <div slot="label">
        <span style="color:#ff0000">*</span>{{ parentNoTitle1 }}
      </div>
      <el-select
        v-model="specialSceneId"
        style="width: 635px" placeholder="请选择" @change="banding">
        <el-option
          v-for="(item, value) in specialSceneMap"
          :key="value"
          :label="item"
          :value="value"
        />
      </el-select>
    </el-form-item>
  </div>
</template>

<script>
  import {m, notify} from "@/store/yg/common/local";
  import {ajax} from "@/store/yg/common/utils";
  import axios from "axios";
  import * as constant from "@/store/yg/common/constant";

  export default {

    data() {
      return {
        parentNoTitle: "物流方法",
        parentNoTitle1: "特殊要求场景",
        shippingWay:"",
        logisticsMethodMap:[],
        specialSceneId:"",
        specialSceneMap:[],
        UserId:"",
      };
    },
    mounted() {
      this.initMothod();
    },
    methods: {
      initMothod(){
        this.logisticsMethodMap=this.$store.state.edit.entry.sources["logisticsMethodSource"]
        this.specialSceneId =this.$store.state.edit.row["specialSceneId"]
        this.shippingWay=this.$store.state.edit.row["shippingWay"]
        this.userId=this.$store.state.auth.user.id;
        var params = {};
        params["UserId"] = this.userId;
        params["shippingWay"] = this.shippingWay;
        console.log("params:",params)
        ajax("findSpecialScene", params).then(
          res => {
            this.specialSceneMap = res.data;
          },
          error => {
            console.log(error);
          }
        );
      },
      initSpecialScene(){
        this.specialSceneMap=[];
        this.specialSceneId="";
        var params = {};
        params["UserId"] = this.userId;
        params["shippingWay"] = this.shippingWay;
        ajax("findSpecialScene", params).then(
          res => {
            this.specialSceneMap = res.data;
          },
          error => {
            console.log(error);
          }
        );
      },
      banding(){
        this.$store.state.edit.row["specialSceneId"]=this.specialSceneId
        this.$store.state.edit.row["shippingWay"]=this.shippingWay
      }
    }
  };
</script>

<style>
  .mail {
    text-align: left;
  }

  .normal-type .el-form-item__content {
    padding: 0 5px 0 15px;
  }
</style>
